
package com.unism.data.service;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

import org.mybatis.spring.SqlSessionTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import com.unism.common.mybatis.BasePojo;
/**
 * A data access object (DAO) providing persistence and search support for TEnum
 * entities. Transaction control of the save(), update() and delete() operations
 * can directly support Spring container-managed transactions or they can be
 * augmented to handle user-managed Spring transactions. Each of these methods
 * provides additional information for how to configure it for the desired type
 * of transaction control.
 * 
 * @see com.TEnum.TEnum
 * @author MyEclipse Persistence Tools
 */

public  class BaseService <T extends BasePojo> {
	private Class<T> clazz;
	@Autowired
	private SqlSessionTemplate sqlSession;
	private final Logger log = LoggerFactory.getLogger(BaseService.class);
	public BaseService(){
		Type type = this.getClass().getGenericSuperclass();
		//强转为子类，目的是能够使用子类的获取参数class类型的方法
		ParameterizedType ptype = (ParameterizedType) type;
		//获取class
		this.clazz = (Class<T>) ptype.getActualTypeArguments()[0];
	}
	public SqlSessionTemplate getSqlSession() {
		return sqlSession;
	}
	public void setSqlSession(SqlSessionTemplate sqlSession) {
		this.sqlSession = sqlSession;
	}
	public Class<T> getClazz() {
		return clazz;
	}
	public void setClazz(Class<T> clazz) {
		this.clazz = clazz;
	}
}